#pragma once
#include "SQLiteCpp/Database.h"
#include <thread>
#include <mutex>


//#include "CodeListUpdate.pb.h"

class XDB {
  public:
    XDB();
    ~XDB();
    
  public:
    void initDB();
    void closeDB();
    
    //void updateCodes(const google::protobuf::RepeatedPtrField<XCode> &codes);
    //void getAllCodes(google::protobuf::RepeatedPtrField<XCode> &codes);
    
    uint32_t getCodeVersion();
    
  private:
    SQLite::Database         m_db;
    std::atomic_bool         m_quit = false;
    std::mutex               m_mutex;
    uint32_t                 m_last_version = 0;
    
};

extern  XDB &getXDB();
#define xDB getXDB()